using System;
using System.Data;
using System.Configuration;
using System.Web;		  
using System.Drawing;    

namespace Possan.Graphics.Filters
{							 
	public class SetOpacity : IBaseFilter
	{
		public int Opacity;

		public string ParameterDefinition
		{
			get
			{
				     return null;
			}
		}

		public SetOpacity()
		{
			Opacity = 50;
		}

		public Bitmap Filter(Bitmap bmp)
		{
			Bitmap bmp2 = new Bitmap(bmp.Width, bmp.Height);
			bmp2.SetResolution(bmp.HorizontalResolution, bmp.VerticalResolution);
			for (int v = 0; v < bmp.Height ;  v++)
			{
				for (int u = 0; u < bmp.Width ;  u++)
				{
					Color oldcolor = bmp.GetPixel(u, v);
					int newalpha = (oldcolor.A * Opacity) / 100;
					Color newcolor = System.Drawing.Color.FromArgb(newalpha, oldcolor);
					bmp2.SetPixel(u, v, newcolor);
				}
			}
			     return bmp2;
		}
						  
	}
}





